<template>
  <el-button text @click="dialogVisible = true">{{
    props.type === true ? "动态参数" : "静态属性"
  }}</el-button>
  <el-dialog
    v-model="dialogVisible"
    :title="props.type === true ? '动态参数' : '静态属性'"
    width="30%"
  >
    <div>
      <el-form-item :label="props.type === true ? '动态参数' : '静态属性'">
        <el-input v-model.trim="inputAff" />
      </el-form-item>
    </div>
    <!-- 插槽 -->
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="changeWinState(0)">取消</el-button>
        <el-button type="primary" @click="changeWinState(1)"
          >确认</el-button
        >
      </span>
    </template>
  </el-dialog>
</template>

<script lang="ts" setup>
import { ref } from "vue";
import { ElMessageBox } from "element-plus";
const props = defineProps(["type","getConfirm"]);

const dialogVisible = ref(false);
const inputAff = ref();

// 关闭弹窗事件
const handleClose = (done: () => void) => {
  done();
};
const emit = defineEmits(["getConfirm"])

// 确认和取消
const changeWinState = (type:any) => {
  // 取消
 if(type===0)dialogVisible.value=false
  // 确认  
 if(type===1){
    // 传给父组件
    emit("getConfirm",inputAff)
    inputAff.value=""
    // 修改状态隐藏弹出框
    dialogVisible.value=false
 }
};
</script>
<style scoped lang="scss">
.dialog-footer button:first-child {
  margin-right: 10px;
}
.el-button{
  width: 100px;
  background-color: #409EFF !important;
  color: white !important;
  margin-bottom: 10px !important;
}
</style>
